package com.qf.controller;

import com.qf.dto.OrdersDto;
import com.qf.entity.Address;
import com.qf.entity.Orders;
import com.qf.service.OrdersService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Orders)表控制层
 *
 * @author makejava
 * @since 2020-07-03 09:49:21
 */
@CrossOrigin
@RestController
@RequestMapping("orders")
public class OrdersController {

    String ono1;
    /**
     * 服务对象
     */
    @Resource
    private OrdersService ordersService;


    @GetMapping("getOrder")
    public List<OrdersDto> showOrders() {
        return ordersService.getOrders();
    }

    @GetMapping("touid")
    public List<Address> getAddressByUserId(int userid,String ono) {
        ono1=ono;
        return ordersService.getAddressByUserId(userid);
    }

    @RequestMapping("updaddress")
    public Integer changeOrdersAdress(int aid) {
        Integer i = ordersService.updOrderAdress(ono1, aid);
        return i == null ? 0 : i;
    }
}